#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import os
from mie.xlogger.klog import klog

klog.to_stdout()


class calltag(object):
    def __call__(self, fn):
        def cuddle(*args, **kwargs):
            klog.d("INTO: %s" % fn.func_name.rjust(36))
            result = fn(*args, **kwargs)
            klog.d("EXIT: %s" % fn.func_name.rjust(36))
            return result

        return cuddle


def getdir(f):
    fp = os.readlink(f) if os.path.islink(f) else f
    return os.path.realpath(os.path.dirname(fp))
